<template>
  <div class="search">
    <div class="shop-item" v-for="(item, index) in shopsList" :key="index">
      <div class="shop-info">
        <img :src="item.shop_img" alt="" />
        <div class="infos">
          <div class="title">
            {{ item.shop_name }}
            <div class="btn">收藏店铺</div>
          </div>
          <div class="attention">119人关注</div>
          <div class="val">
            <div class="item">
              <span>关注</span><b>{{ item.shop_collection }}</b>
            </div>
            <div class="item">
              <span>新品</span><b>{{ item.shop_new }}</b>
            </div>
            <div class="item">
              <span>促销</span><b>{{ item.shop_promotion }}</b>
            </div>
          </div>
        </div>
      </div>
      <div class="goods-list">
        <div class="item" v-for="i in 5" :key="i">
          <img
            src="https://dss0.bdstatic.com/6Ox1bjeh1BF3odCf/it/u=1209066132,765028587&fm=218&app=92&f=JPEG?w=121&h=75&s=7AA517668FA1ACC0161DB7B30200F085"
            alt=""
          />
          <div class="title">【今日特价】满10送2 威力狮钢丝钳 老虎…</div>
        </div>
      </div>
    </div>
    <center class="page-box">
      <Pages1
        :total="false"
        :pages="false"
        :jump="false"
        v-model="query.current"
        :size="query.length"
        :count="query.total"
        @change="getShopsList"
      />
    </center>
  </div>
</template>

<script>
import api from "@/api";
// import GoodsItem6 from "@/components/GoodsItem/GoodsItem6.vue";
import Pages1 from "@/components/Pages/Pages1.vue";
export default {
  name: "Search",
  components: { Pages1 },
  data() {
    return {
      query: {
        current: 1,
        length: 5,
        total: 0,
      },
      shopsList: [], // 店铺列表
    };
  },
  created() {
    this.getShopsList();
  },
  methods: {
    async getShopsList() {
      let loading = this.loadingMsg();
      let result = await api.SHOP_STREET(this.query);
      loading.close();
      this.shopsList = result.data;
      this.query.current = result.current;
      this.query.length = result.length;
      this.query.total = result.total;
      this.$forceUpdate();
      window.scrollTo(0, 0);
    },
  },
};
</script>

<style lang="scss" scoped>
.search {
  margin-bottom: 20px;
  .shop-item {
    max-width: 1200px;
    margin: 20px auto 0;
    box-sizing: border-box;
    height: 204px;
    background: #ffffff;
    border-radius: 5px;
    border: 1px solid #f0f0f0;
    padding: 20px;
    display: flex;
    .shop-info {
      display: flex;
      flex: 1;
      img {
        width: 94px;
        height: 94px;
        border-radius: 2px;
        margin-right: 20px;
      }
      .infos {
        flex: 1;
        width: 0;
        margin-right: 10px;
        .title {
          font-size: 18px;
          font-weight: 600;
          color: #333333;
          line-height: 25px;
          display: flex;
          align-items: center;
          .btn {
            margin-left: 20px;
            width: 120px;
            height: 28px;
            background: #d52c1a;
            border-radius: 5px;
            border: 1px solid #d52c1a;
            font-size: 14px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #ffffff;
          }
        }
        .attention {
          font-size: 16px;
          font-weight: 400;
          color: #999999;
          margin: 12px 0;
        }
        .val {
          display: flex;
          align-items: center;
          font-size: 16px;
          color: #666666;
          line-height: 22px;
          margin-right: 20px;
          b {
            color: #dc2c1a;
            margin: 0 10px;
            font-weight: 400;
          }
        }
      }
    }
    .goods-list {
      display: flex;
      & .item:first-child {
        margin-left: 0;
      }
      .item {
        width: 120px;
        margin-left: 40px;
        img {
          width: 120px;
          height: 120px;
          border-radius: 5px;
        }
        .title {
          margin-top: 10px;
          font-size: 12px;
          color: #333333;
          line-height: 17px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
      }
    }
  }
  .page-box {
    margin-top: 20px;
  }
}
</style>
